<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/11
 * Time: 17:54
 */

namespace app\service;

use app\models\Customer;

class PayService
{
    /**校验银行支出客户信息是否正确
     * @param $list
     * @return mixed
     */
    public function validateBankCustomer($list)
    {
        $customerArr = [];
        foreach ($list as $v) {
            $customerArr[] = $v['number'];
        }
        //判断客户编号和客户名称是否一致
        $customerModel = new Customer();
        $customerList = $customerModel->getCustomerByNum($customerArr);

        foreach ($list as $k => $v) {
            if ($v['number'] && isset($customerList[$v['number']])) {
                if ($v['customer_name'] == $customerList[$v['number']]) {
                    $list[$k]['same'] = true;
                } else {
                    $list[$k]['same'] = false;
                }
            } else {
                $list[$k]['same'] = false;
            }

        }
        return $list;
    }
}